import java.sql.*;
import java.util.*;

/**
 * @author ：hzs
 * @date ：Created in 2020/12/8 18:54
 * @description：
 * @modified By：
 * @version: $
 */
public class Test {

    final public static String JDBCUrl = "jdbc:mysql://1.15.136.97:3306/lunwen?useSSL=false&serverTimezone=GMT%2B8";
    final public static String userName = "niu";
    final public static String passWord = "12300zaq";
    final public static String className = "com.mysql.cj.jdbc.Driver";

    public static void main(String[] args) {




        try {
            Class.forName(className);
            Connection connection = DriverManager.getConnection(JDBCUrl, userName, passWord);
            String sql = "SELECT * FROM zhanghaomima";
            try (Statement statement = connection.createStatement()) {
                ResultSet resultSet1 = statement.executeQuery(sql);
                List<List<Object>> result = new ArrayList<>();
                while (resultSet1.next()) {
                    int columnCount = resultSet1.getMetaData().getColumnCount();
                    List<Object> line = new ArrayList<>();
                    for (int i = 1; i <= columnCount; i++) {
                        line.add(resultSet1.getObject(i));
                    }
                    result.add(line);
                }
                System.out.println(result.toString());
            } catch (Exception e) {
                e.printStackTrace();
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }


    }

}
